Skip to content

Update to Node 24#1331

Draft
josephjclark wants to merge 17 commits intorelease/nextfrom
node-24
Draft

Update to Node 24#1331
josephjclark wants to merge 17 commits intorelease/nextfrom
node-24

Conversation

@josephjclark
Copy link
Copy Markdown
Collaborator

Short Description

Fixes #1326

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

@github-project-automation github-project-automation bot moved this to New Issues in Core Mar 20, 2026
@josephjclark
Copy link
Copy Markdown
Collaborator Author

josephjclark commented Mar 20, 2026

hmm there's definitely some strange resolution stuff happening in node 24. http 6 seems to be broken (even on a basic node.js import). node 22 is fine and http v8 is fine. What's happening in http6 and node 24?

Nothing in the migration guide which might explain this

@josephjclark
Copy link
Copy Markdown
Collaborator Author

I can see that the exports from the modules are the same. common functions work great. But all http functions fail.

@josephjclark josephjclark marked this pull request as draft March 23, 2026 11:37
@josephjclark
Copy link
Copy Markdown
Collaborator Author

this problem sort of exists anyway. If I go into adaptors and run from a local build, using production openfn and node 24, I get this same error:

SyntaxError: The requested module '@openfn/language-http' does not provide an export named 'get'

if I switch to node 22 in the adapors repo and re-run the cli, it works great

// Safer for now to just use the CJS import
if (pkg.main) {
main = pkg.main;
// Find the best ESM entrypoint
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scary change here

It looks like the problems I'm (luckily!) catching in tests is that node24 has changed the module loader a bit and support for CJS feels flaky. That's OK, I'd much rather be using ESM anyway.

So this change prefers the ESM import to the CJS one.

I just worry about whether things are going to break?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, some things break. Some older packages fail to import through the ESM loader (basically if they import paths which don't have a .js extension)

@josephjclark josephjclark changed the base branch from main to release/next March 30, 2026 10:19
@josephjclark
Copy link
Copy Markdown
Collaborator Author

I think integration tests fails are just flaky now.

I don't understand the unit test fails - we seem to get a SIGTERM half way through the tests

@josephjclark
Copy link
Copy Markdown
Collaborator Author

josephjclark commented Mar 31, 2026

Seeing lots of errors like this creeping out of tests:

ImportError: Failed to import module @openfn/language-collections from /home/joe/repo/openfn/kit/integration-tests/worker/tmp/repo/attempts/node_modules/@openfn/language-collections_0.5.0/dist/index.js?cache=fdc0a76b-6e3c-4ed0-9103-1a020b0b2e7d (Cannot find module '/home/joe/repo/openfn/kit/integration-tests/worker/tmp/repo/attempts/node_modules/stream-json/filters/Pick' imported from /home/joe/repo/openfn/kit/integration-tests/worker/tmp/repo/attempts/node_modules/@openfn/language-collections_0.5.0/dist/index.js
Did you mean to import "stream-json/filters/Pick.js"?)

What's happening is we've switched to loading modules in the old CJS format and preferring the new ESM format.

But there are subtleties in the import which means that some import statements inside our dependencies no longer work - like the above one coming out of stream-json from collections. But we also see problems in lodash from some versions of common.

What concerns me is that import statements we are not in control of are causing the runtime to crash. It's mostly old versions but still, I don't want things to start suddenly breaking in the worker.

The old runtime import, the CJS import, works on both node 22 and 24. The new import breaks with these particular patterns on node 22 and 24.

[statePath]: state,
[outputPath]: '{}',
[pnpm]: mock.load(pnpm, {}),
[recastPath]: mock.load(recastPath, {}),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bonus: this will make tests run quicker. Should I do this in more places?

}
);

test.serial('pull: should pull a simple project', async (t) => {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this because it's failing, but we have better coverage of this in integration tests now

josephjclark and others added 7 commits March 31, 2026 18:28
…1343)

* add a custom module loader to handle older imports without .js extensions

* types

* typo

* fix module loader path

* fix module import and update tests

* use esmhook in metadata

* remove stupid logging

* remove debug flag from tests
Hoping this will fix failures in CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

Update repo to node 24

2 participants